use serde::Deserialize;

#[derive(Deserialize)]
pub struct Config {
    pub game: GameConfig,
    pub audio: AudioConfig,
    pub ai: AIConfig,
}

#[derive(Deserialize)]
pub struct GameConfig {
    pub window_width: f32,
    pub window_height: f32,
    pub target_fps: u32,
    pub max_tanks: usize,
}

#[derive(Deserialize)]
pub struct AudioConfig {
    pub master_volume: f32,
    pub sfx_volume: f32,
    pub music_volume: f32,
    pub dynamic_bgm: bool,
}

#[derive(Deserialize)]
pub struct AIConfig {
    pub perception_radius: f32,
    pub decision_frequency: f32, // 决策频率（次/秒）
    pub enable_team_coordination: bool,
}

impl Config {
    pub fn load() -> Self {
        // 默认配置
        Config {
            game: GameConfig {
                window_width: 1024.0,
                window_height: 768.0,
                target_fps: 60,
                max_tanks: 8,
            },
            audio: AudioConfig {
                master_volume: 1.0,
                sfx_volume: 1.0,
                music_volume: 1.0,
                dynamic_bgm: true,
            },
            ai: AIConfig {
                perception_radius: 200.0,
                decision_frequency: 10.0,
                enable_team_coordination: true,
            },
        }
    }
}